{% extends 'base.html' %}
{% block head %}
<script type="text/javascript">
    function pay(oid){
        $.get('/order/pay&'+oid+'/', function(data){
            if(data.status == 0){
                alert("支付失败!");
            }
            else{
                alert("支付成功!");
                window.location.href = '/';
            }
        });
    }

    $(function(){
        var total0 = 0, total1 = 0;
        $('.col04').each(function(){
            var count = $(this).prev().text();
            var price = $(this).prev().prev().find('em').text();
            $(this).text(count*price);
        });
    })
</script>
{% endblock head %}
{% block content %}
<div class="main_con clearfix">
    <div class="left_menu_con clearfix">
        <h3>用户中心</h3>
        <ul>
            <li><a href="/user/info/">· 个人信息</a></li>
            <li><a href="" class="active">· 全部订单</a></li>
            <li><a href="/user/site/">· 收货地址</a></li>
        </ul>
    </div>
    <div class="right_content clearfix">
            <h3 class="common_title2">全部订单</h3>
        {% for order in page %}
            <ul class="order_list_th w978 clearfix">
                <li class="col01">{{ order.odate|date:"Y-m-d" }}</li>
                <li class="col02">订单号：{{ order.oid }}</li>
            {% if order.oIspay == 0 %}
                <li class="col02 stress">未支付</li>
            {% elif order.oIspay == 1 %}
                <li class="col02 stress">已支付</li>
            {% endif %}
                <li class="col02">运费：10元</li>
            </ul>

            <table class="order_list_table w980">
                <tbody>
                    <tr>
                        <td width="55%">
                            {% for detail in order.orderdetailinfo_set.all %}
                            <ul class="order_goods_list clearfix">
                                <li class="col01"><img src="/static/{{ detail.goods.gpic }}"></li>
                                <li class="col02">{{ detail.goods.gtitle }}<em>{{ detail.goods.gprice }}</em>元/{{ detail.goods.gunit }}</li>
                                <li class="col03">{{ detail.count }}</li>
                                <li class="col04">11.80元</li>
                            </ul>
                            {% endfor %}
                        </td>
                        <td width="15%" id="total0">{{ order.ototal }}元</td>
                    {% if order.oIspay == 0 %}
                        <td width="15%">待付款</td>
                        <td width="15%"><a href="javascript:pay({{order.oid}});" class="oper_btn">去付款</a></td>
                    {% elif order.oIspay == 1 %}
                        <td width="15%">已付款</td>
                        <td width="15%"><a href="/order/viewlog&{{order.oid}}/" class="oper_btn">查看物流</a></td>
                    {% endif %}
                    </tr>
                </tbody>
            </table>
        {% endfor %}

            <div class="pagenation">
                {% if page.has_previous %}
                    <a href="/user/order{{ page.previous_page_number }}/">&lt;上一页</a>
                {% endif %}
                {% for pindex in plist %}
                    <a href="/user/order{{ pindex }}/"
                    {% if pindex == page.number %}
                         class="active"
                    {% endif %}
                    >{{ pindex }}</a>
                {% endfor %}
                {% if page.has_next %}
				    <a href="/user/order{{ page.next_page_number }}/">下一页&gt;</a>
                {% endif %}
			</div>
    </div>
</div>
{% endblock content %}